<script setup>
import { watch, ref, nextTick } from 'vue';
import useLayOutSettingStore from '@/store/modules/setting';
let lay = useLayOutSettingStore();
let falge = ref(true);
//监听仓库内部数据是否变化，如果仓库内部数据变化，则点击了刷新
watch(
  () => lay.refsh,
  () => {
    console.log('刷新了');
    falge.value = false;
    nextTick(() => {
      falge.value = true;
    });
  }
);
</script>
<template>
  <router-view v-slot="{ Component }">
    <transition name="fade" appear mode="out-in">
      <!-- 渲染layout一级路由 的子路由 -->
      <component :is="Component" v-if="falge" />
    </transition>
  </router-view>
</template>

<style scoped>
.fade-enter {
  opacity: 0;
  transform: translateY(30px) scale(0.8);
}

.fade-enter-to {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.fade-leave {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.fade-leave-to {
  opacity: 0;
  transform: translateY(-30px) scale(0.8);
}

.fade-enter-active,
.fade-leave-active {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  /* 使用Material Design缓动函数，使动画更流畅 */
}
</style>
